package com.qf.kele02.config;

import com.qf.kele02.filter.MyFilter;
import com.qf.kele02.propertiess.MyFilterProperties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: 可乐
 * @Description:
 * @CreateTime: 2022-10-19  19:45
 */
@Configuration
@EnableConfigurationProperties(MyFilterProperties.class)
public class MyFilterConfig {
	@Value("${qf.name.name}")
	private String name;

	@Bean
	public FilterRegistrationBean< MyFilter > demoFilterFilterRegistrationBean( ) {
		final FilterRegistrationBean< MyFilter > demoFilterFilterRegistrationBean=new FilterRegistrationBean<>( );
		demoFilterFilterRegistrationBean.addUrlPatterns( "/hi" );
		final MyFilter filter=new MyFilter( );
		filter.setName( name );
		demoFilterFilterRegistrationBean.setFilter( filter );
		return demoFilterFilterRegistrationBean;
	}
}
